package com.foreverwin.generator.util;

import java.util.HashMap;
import java.util.Map;

public class Global {

    private static final ThreadLocal<Map<String,Object>> configs = new InheritableThreadLocal<Map<String, Object>>();

    public static void loadMap( Map<String,Object> map ){
        if( configs.get() == null ){
            configs.set( new HashMap<String, Object>());
        }
        configs.get().putAll( map );
    }

    public static String getStringConfig( String key ){
        Map<String,Object> map = configs.get();
        return map == null ? null : (String)map.get( key );
    }

    public static Boolean getBoolConfig( String key ){
        Map<String,Object> map = configs.get();
        return map == null ? null : (Boolean)map.get( key );
    }

    public static Integer getIntConfig( String key ){
        Map<String,Object> map = configs.get();
        return map == null ? null : (Integer)map.get( key );
    }

}
